package com.app.micaihu.view.main.game.view;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.app.micaihu.R;
import com.app.micaihu.app.AppApplication;
import com.app.micaihu.bean.game.GameCenterEntity;
import com.app.micaihu.custom.view.CustomImageView;
import com.app.utils.util.image.LoadImageUtils;
import com.facebook.drawee.generic.RoundingParams;

/**
 * 排行榜游戏
 * Created by linkai on 2017/3/14.
 */
public class RanklGameView extends LinearLayout {

    private Context context;
    private GameCenterEntity gameRelated;
    private int position;

    public RanklGameView(Context context, GameCenterEntity gameRelated, int position) {
        super(context);
        this.context = context;
        this.gameRelated = gameRelated;
        this.position = position;
        init();
    }


    /**
     * 初始化 视图
     */
    private void init() {
        inflate(context, R.layout.view_rankgame, this);
        CustomImageView civGamePic = (CustomImageView) findViewById(R.id.civ_gamepic);
        TextView tvGameTitle = (TextView) findViewById(R.id.tv_game_name);
        ImageView rankimg = (ImageView) findViewById(R.id.iv_rank_num);
        if (position == 0) {
            rankimg.setImageResource(R.drawable.game_listic_one);
            rankimg.setVisibility(View.VISIBLE);
        } else if (position == 1) {
            rankimg.setImageResource(R.drawable.game_listic_two);
            rankimg.setVisibility(View.VISIBLE);
        } else if (position == 2) {
            rankimg.setImageResource(R.drawable.game_listic_three);
            rankimg.setVisibility(View.VISIBLE);
        }
        LoadImageUtils.getInstance().loadImage(civGamePic, this.gameRelated.getAppIcon());
        civGamePic.getHierarchy().setRoundingParams(new RoundingParams().setCornersRadius(28.0f));


        tvGameTitle.setText(this.gameRelated.getArticleTitle());
        this.setTag(this.gameRelated.getArticleId());
    }
}
